<template>
  <div id="backend" style="width: 100%;height: 700px">
    <div class="navbar" style="height: 70px">
      <div class="navbar-left">
        <img src="@/assets/images/logo.png" alt="Logo" class="logo">
      </div>
      <div class="navbar-right">
        <div class="user-profile" @mouseover="showTooltip = true" @mouseleave="showTooltip = false">
          <img src="@/assets/images/reviewer-3.jpg" alt="User Avatar" class="avatar" style="margin: 10px">
          <div v-if="showTooltip" class="tooltip">退出系统</div>
        </div>
      </div>
    </div>
    <div class="content" style="height: 870px;margin: 0">
      <el-container style="height: 100%;">
        <el-aside width="200px">
          <el-menu
            default-active="1"
            class="el-menu-vertical-demo"
            unique-opened
          >
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-document"></i>
                <span>用户管理</span>
              </template>
              <el-menu-item index="1-1" @click="menuSelect('/backend/user')"><i class="el-icon-user"></i>普通用户管理</el-menu-item>
              <el-submenu index="1-1">
                <template slot="title">
                  <i class="el-icon-office-building"></i>
                  <span>商户管理</span>
                </template>
                <el-menu-item index="1-1-1" @click="menuSelect('/backend/merchantReview')">商户审核</el-menu-item>
                <el-menu-item index="1-1-2" @click="menuSelect('/backend/merchant')">商户信息</el-menu-item>
              </el-submenu>
              <el-submenu index="1-2">
                <template slot="title">
                  <i class="el-icon-truck"></i>
                  <span>供应商管理</span>
                </template>
                <el-menu-item index="1-2-1" @click="menuSelect('/backend/supplierReview')">供应商审核</el-menu-item>
                <el-menu-item index="1-2-2" @click="menuSelect('/backend/supplier')">供应商信息</el-menu-item>
              </el-submenu>
            </el-submenu>

            <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-box"></i>
                <span>仓库管理</span>
              </template>
                <el-submenu index="2-1">
                  <template slot="title">
                    <i class="el-icon-box"></i>
                    <span>仓库管理</span>
                  </template>
                  <el-menu-item index="2-1-1" @click="menuSelect('/backend/warehouseReview')">仓库审核</el-menu-item>
                  <el-menu-item index="2-1-1" @click="menuSelect('/backend/warehouseList')">仓库列表</el-menu-item>
                </el-submenu>
                <el-submenu index="2-2">
                  <template slot="title">
                    <i class="el-icon-bicycle"></i>
                    <span>入库管理</span>
                  </template>
                  <el-menu-item index="4-1-1" @click="menuSelect('/backend/warehousing')">入库审核</el-menu-item>
                </el-submenu>
                <el-submenu index="2-3">
                  <template slot="title">
                    <i class="el-icon-ship"></i>
                    <span>出库管理</span>
                  </template>
                  <el-menu-item index="2-1-1" @click="menuSelect('/backend/dispatchWarehouse')">出库审核</el-menu-item>
                </el-submenu>
              <el-menu-item index="动态库存" @click="menuSelect('/backend/stock')"><i class="el-icon-box"></i>动态库存</el-menu-item>
            </el-submenu>

            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-truck"></i>
                <span>订单管理</span>
              </template>
                <el-submenu index="3-1">
                  <template slot="title">
                    <i class="el-icon-shopping-cart-1"></i>
                    <span>采购管理</span>
                  </template>
                  <el-menu-item index="3-1-1" @click="menuSelect('/backend/PurchaseRequisition')">采购申请</el-menu-item>
                  <el-menu-item index="3-1-2" @click="menuSelect('/backend/purchaseReview')">采购审核</el-menu-item>
                  <el-menu-item index="3-1-3" @click="menuSelect('/backend/orderList')">采购订单</el-menu-item>
                </el-submenu>
              <el-submenu index="3-2">
                <template slot="title">
                  <i class="el-icon-shopping-bag-1"></i>
                  <span>订单管理</span>
                </template>
                <el-menu-item index="3-3-1" @click="menuSelect('/backend/order')">全部订单</el-menu-item>
                <el-menu-item index="3-3-2" @click="menuSelect('/backend/AllocateGoods')">调拨商品</el-menu-item>
                <el-menu-item index="3-3-3" @click="menuSelect('/backend/returnProduct')">退货退款</el-menu-item>
              </el-submenu>
            </el-submenu>

            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-shopping-cart-full"></i>
                <span>商品管理</span>
              </template>
              <el-menu-item index="4-1" @click="menuSelect('/backend/GoodsType')">商品类型管理</el-menu-item>
              <el-menu-item index="4-2" @click="menuSelect('/backend/Goods')">商品信息管理</el-menu-item>
            </el-submenu>

            <el-submenu index="5">
              <template slot="title">
                <i class="el-icon-monitor"></i>
                <span>结账管理</span>
              </template>
              <el-menu-item index="5-1" @click="menuSelect('/backend/MerchantAccount')">商户结账</el-menu-item>
              <el-menu-item index="5-2" @click="menuSelect('/backend/SupplierAccount')">供应商结账</el-menu-item>
              <el-menu-item index="5-3" @click="menuSelect('/backend/checkOutRv')">结账审核</el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-container style="height: 100%;background-color: #e7ebf0">
          <el-main>
            <router-view></router-view>
          </el-main>
        </el-container>
      </el-container>
    </div>
  </div>
</template>

<script>
import order from "@/components/BackEnd_body/Order.vue";
import returnProduct from "@/components/BackEnd_body/ReturnProduct.vue";

export default {
  computed: {
    returnProduct() {
      return returnProduct
    },
    order() {
      return order
    }
  },
  data() {
    return {
      showTooltip: false
    }
  },
  methods: {
    menuSelect(url) {
      if (this.$route.path !== url) {
        this.$router.push(url);
      }
    }
  }
}
</script>

<style scoped>
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #333;
  color: white;
}

.navbar-left {
  display: flex;
  align-items: center;
}

.logo {
  height: 40px;
}

.navbar-right {
  display: flex;
  align-items: center;
}

.user-profile {
  position: relative;
  cursor: pointer;
}

.avatar {
  height: 40px;
  border-radius: 50%;
}

.tooltip {
  position: absolute;
  top: 100%;
  right: 0;
  background-color: #333;
  color: white;
  padding: 5px 10px;
  border-radius: 5px;
  white-space: nowrap;
  z-index: 1;
}

.content {
  margin: 20px;
  border-top: none;
}

.el-header {
  background-color: white;
  color: white;
  line-height: 60px;
}

.el-aside {
  background-color: white;
  color: white;
  text-align: center;
  line-height: 200px;
  height: 100%;
}

.el-main {
  background-color: white;
  //color: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
  margin: 10px;
  border-radius: 5px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-menu {
  background-color: white; /* 修改背景颜色为白色 */
  color: white; /* 修改字体颜色为白色 */
  height: 100%;
}
</style>
